#ifndef MPGDECODER_HPP
#define MPGDECODER_HPP

#include <mad.h>
#include "Decoder.hpp"

#define MAD_MIN_24_BITS_VALUE -8388608
#define MAD_MAX_24_BITS_VALUE  8388607
#define MAD_RANGE 16777215

/// @brief MP3 decoding class
class MpgDecoder : public Decoder {
    private:
        int error;
        struct mad_stream stream;
        struct mad_frame frame;
        struct mad_synth synth;
        struct mad_header header;
        unsigned char *buffer;
        unsigned int size;
    public:
        bool load(const char* filename, bool silence=false);
        void close();
        int decode(float *data, unsigned long frames);
        bool seek(unsigned int time);
        MpgDecoder();
        ~MpgDecoder();
};

#endif // MPGDECODER_HPP
